#include <Box2D.h>
#include "common.h"

#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT jfloat JNICALL Java_b2PrismaticJointDef_jni_1b2PrismaticJointDef_1Initialize
  (JNIEnv *env, jclass cls, jint localAnchorA, jint localAnchorB, jint localAxisA
	jint bodyA, jint bodyB, jint anchor, jint axis)
{
	b2Vec2* _localAnchorA = (b2Vec2*)localAnchorA;
	b2Vec2* _localAnchorB = (b2Vec2*)localAnchorB;
	b2Vec2* _localAxisA = (b2Vec2*)localAxisA;
	b2Body* _bodyA = (b2Body*)bodyA;
	b2Body* _bodyB = (b2Body*)bodyB;
	b2Vec2* _anchor = (b2Vec2*)anchor;
	b2Vec2* _axis = (b2Vec2*)axis;

	//(Box2D: localAnchorA = bodyA->GetLocalPoint(anchor);)
	*_localAnchorA = _bodyA->GetLocalPoint(*_anchor);

	//(Box2D: localAxisA = bodyA->GetLocalVector(axis);)
	*_localaxisA = _bodyA->GetLocalVector(*_axis);

	//(Box2D: localAnchorB = bodyB->GetLocalPoint(anchor);)
	*_localAnchorB = _bodyB->GetLocalPoint(*_anchor);

	return (_bodyB->GetAngle() - _bodyA->GetAngle());
}

#ifdef __cplusplus
}
#endif
